package com.itheima.service.impl;
import com.itheima.dao.RoleDeleteMapper;
import com.itheima.dao.RoleMapper;
import com.itheima.dao.RoleSaveMapper;
import com.itheima.dao.RoleUpdateMapper;
import com.itheima.domain.QueryByGender;
import com.itheima.domain.Role;
import com.itheima.domain.TurnPage;
import com.itheima.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;
    @Autowired
    private RoleSaveMapper roleSaveMapper;
    @Autowired
    private RoleDeleteMapper roleDeleteMapper;
    @Autowired
    private RoleUpdateMapper roleUpdateMapper;



    public List<Role> findAll() throws IOException {
        return roleMapper.findAll();
    }


    public List<Role> turnPages(TurnPage turnPage) {
        return roleMapper.turnPages(turnPage);
    }

    public List<Role> findByGender(QueryByGender queryByGender) {
        return roleMapper.findByGender(queryByGender);
    }


    public List<Role> findById(int id) {
        return roleMapper.findById(id);
    }

    public List<Role> RankBySalary(TurnPage turnPage) {
        return roleMapper.RankBySalary(turnPage);
    }

    public int countId() {
        return roleMapper.countId();
    }

    public int countGender(String gender) {
        return roleMapper.countGender(gender);
    }


    public void UpdateById(Role role) {
        roleUpdateMapper.UpdateById(role);
    }

    public void DeleteById(int id) {
        roleDeleteMapper.DeleteById(id);
    }

    public void DeleteByName(String rolename) {
        roleDeleteMapper.DeleteByName(rolename);
    }

    public void SaveRole(Role role) {
        roleSaveMapper.SaveRole(role);
    }
}
